FindIndexTest = TestCase("FindIndex Test");

FindIndexTest.prototype.testSanityFindIndex = function() {
    var tsk = new b2b.Task();
    var actual_result = tsk.findIndex("abc", "b");
};

FindIndexTest.prototype.testMinusOneWhenSearchabelIsLonger = function() {
    var tsk = new b2b.Task();
    inputString = "short";
    s = "Longer string";
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, -1);
};

FindIndexTest.prototype.testMinusOneWhenSearchableIsEmpty = function() {
    var tsk = new b2b.Task();
    inputString = "Valid big string";
    s = "";
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, -1);
};

FindIndexTest.prototype.testMinusOneWhenBigIsEmpty = function() {
    var tsk = new b2b.Task();
    inputString = "";
    s = "Valid s string";
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, -1);
};

FindIndexTest.prototype.testMinusOneWhenBothAreEmpty = function() {
    var tsk = new b2b.Task();
    inputString = "";
    s = "";
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, -1);
};

FindIndexTest.prototype.testIndexWhenSearchableIsTheSame = function() {
    var tsk = new b2b.Task();
    inputString = "abc";
    s = "abc";
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, 0);
};

FindIndexTest.prototype.testIndexZero = function() {
    var tsk = new b2b.Task();
    inputString = "abcdefgh";
    s = "abc";
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, 0);
};

FindIndexTest.prototype.testMinusOneWhenSerachableStartsWithTheSameChars = function() {
    var tsk = new b2b.Task();
    inputString = "abcdefgh";
    s = "abX";
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, -1);
};

FindIndexTest.prototype.testIndexAfterFirstPartialOccurance = function() {
    var tsk = new b2b.Task();
    inputString = "xxababcxx";
    s = "abc";
    jstestdriver.console.log(tsk.findIndex(inputString, s));
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, 4);
};

FindIndexTest.prototype.testIndexWhenSearchableMatchedInTheMiddle = function() {
    var tsk = new b2b.Task();
    inputString = "abcdefgh";
    s = "bcd";
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, 1);
};

FindIndexTest.prototype.testIndexWhenSearchableMatchedInTheEnd = function() {
    var tsk = new b2b.Task();
    inputString = "abcdefgh";
    s = "fgh";
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, 5);
};

FindIndexTest.prototype.testMinusOneWhenSearchablePartiallyMatchesTheEnd = function() {
    var tsk = new b2b.Task();
    inputString = "abcdefgh";
    s = "ghi";
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, -1);
};

FindIndexTest.prototype.testIndexInMultilineBeforeNewLine = function() {
    var tsk = new b2b.Task();
    inputString = "abcd\nefgh";
    s = "bc";
    jstestdriver.console.log(tsk.findIndex(inputString, s));
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, 1);
};

FindIndexTest.prototype.testIndexInMultilineAfterNewLine = function() {
    var tsk = new b2b.Task();
    inputString = "abcd\nefgh";
    s = "fg";
    jstestdriver.console.log(tsk.findIndex(inputString, s));
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, 6);
};

FindIndexTest.prototype.testIndexInMultilineIncludingNewLine = function() {
    var tsk = new b2b.Task();
    inputString = "abcd\nefgh";
    s = "cd\nef";
    jstestdriver.console.log(tsk.findIndex(inputString, s));
    var actual_result = tsk.findIndex(inputString, s);
    assertEquals(actual_result, 2);
};
